Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plane: ICE: fully move to aux function #28655

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

IamPete1
Copy link
Member

This removes the ICE STARTCHN_MIN protections and RC input thresholds instead moving over to those that are applied to all aux functions.

Aux functions do have a min value of 800.

if (in <= RC_MIN_LIMIT_PWM || in >= RC_MAX_LIMIT_PWM) {

This also moves to the aux function threshold values of 1200 and 1800 rather than the 1300 and 1700 that are used now. ICE was also using a longer de-bounce time, 300ms vs 200ms in the RC lib.

This could mean a change in behavior for some users.

We also loose the low PWM on RC failure protection of STARTCHN_MIN.

We gain the ability to trigger the aux function directly from the GCS, so if RC dropout was a issue the recommendation would be to use the MAVLink command.

I don't really see any other nice way of moving forward. One option would be to add a STARTCHN_MIN parameter to the RC_Channel library and apply it to all switches.

A second option would be to add another aux function that would be sent from the GCS and would be ignored if the existing option is setup. So you could do RC switch or GCS, but not both.

@IamPete1 IamPete1 added the Plane label Nov 16, 2024
@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Nov 17, 2024
Copy link
Contributor

@Georacer Georacer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the loss of STARTCHN_MIN functionality: I know that the the control of the ICE is a crucial function. But doing away with this parameter can only mean inadvertent shutoff of the engine, not inadvertent start.

Under that light, is an inadvertent engine shutoff due to bad RC signals more dangerous than other events tied to AUX_FUNCTIONs?
E.g. switching to a different mode or enabling a parachute.

If we are concerned about minimum PWM values doing bad things, this is universal to all AUX_FUNCTIONs and we should do something about it for all of them in its their own library.

One more thing: You also need to modify the quadplane autotest MAV_CMD_DO_ENGINE_CONTROL; L1224 now fails because the AUX_FUNCTION being low doesn't block an engine start after a MAV_CMD_DO_ENGINE_CONTROL. Which I don't understand why, to be honest.

@@ -163,7 +161,8 @@ const AP_Param::GroupInfo AP_ICEngine::var_info[] = {
// @Description: This is a minimum PWM value for engine start channel for an engine stop to be commanded. Setting this value will avoid RC input glitches with low PWM values from causing an unwanted engine stop. A value of zero means any PWM above 800 and below 1300 triggers an engine stop. To stop the engine start channel must above the larger of this value and 800 and below 1300.
// @User: Standard
// @Range: 0 1300
AP_GROUPINFO("STARTCHN_MIN", 16, AP_ICEngine, start_chan_min_pwm, 0),

// 16 was STARTCHN_MIN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it customary that we also delete the parameter description or no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently all the GCSs use param docs generated from master, so If we delete the description it doesn't show up in the GCS for older versions.

Comment on lines -294 to +307
uint16_t cvalue = 1500;
RC_Channel *c = rc().find_channel_for_option(RC_Channel::AUX_FUNC::ICE_START_STOP);
if (c != nullptr && rc().has_valid_input()) {
// get starter control channel
cvalue = c->get_radio_in();

if (cvalue < start_chan_min_pwm) {
cvalue = start_chan_last_value;
}

// snap the input to either 1000, 1500, or 2000
// this is useful to compare a debounce changed value
// while ignoring tiny noise
if (cvalue >= RC_Channel::AUX_PWM_TRIGGER_HIGH) {
cvalue = 2000;
} else if ((cvalue > 800) && (cvalue <= RC_Channel::AUX_PWM_TRIGGER_LOW)) {
cvalue = 1300;
} else {
cvalue = 1500;
}
}

bool should_run = false;
uint32_t now = AP_HAL::millis();


// debounce timer to protect from spurious changes on start_chan rc input
// If the cached value is the same, reset timer
if (start_chan_last_value == cvalue) {
start_chan_last_ms = now;
} else if (now - start_chan_last_ms >= AP_ICENGINE_START_CHAN_DEBOUNCE_MS) {
// if it has changed, and stayed changed for the duration, then use that new value
start_chan_last_value = cvalue;
}

if (state == ICE_START_HEIGHT_DELAY && start_chan_last_value >= RC_Channel::AUX_PWM_TRIGGER_HIGH) {
if ((state == ICE_START_HEIGHT_DELAY) && (aux_pos == RC_Channel::AuxSwitchPos::HIGH)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice cleanup!

@IamPete1
Copy link
Member Author

Regarding the loss of STARTCHN_MIN functionality: I know that the the control of the ICE is a crucial function. But doing away with this parameter can only mean inadvertent shutoff of the engine, not inadvertent start.

Under that light, is an inadvertent engine shutoff due to bad RC signals more dangerous than other events tied to AUX_FUNCTIONs? E.g. switching to a different mode or enabling a parachute.

If we are concerned about minimum PWM values doing bad things, this is universal to all AUX_FUNCTIONs and we should do something about it for all of them in its their own library.

This was originally added as a result of a dodgy RC system not going into failsafe but output all channels at 900. The result was the engine stopped and could not be re-started as there was no starter. All the other options you mention don't have to be on RC, until now RC was the only option for ICE start.

@Georacer
Copy link
Contributor

This was originally added as a result of a dodgy RC system not going into failsafe but output all channels at 900. The result was the engine stopped and could not be re-started as there was no starter. All the other options you mention don't have to be on RC, until now RC was the only option for ICE start.

I get that.
What I'm saying is that:

  • either such an RC malfunction isn't a big deal and so you shouldn't worry about it in this PR.
  • or such an RC malfunction is a big deal and it affects all other AUX_FUNCTIONs, because they can also be tied to RC switches and cause bad things. So again you shouldn't worry about it in this PR, but we should all worry a lot about it in a new PR.

@robertlong13
Copy link
Collaborator

I'm for moving this to be more consistent with our other RC Channels options. I've always wondered why this one didn't get updated with the others.

until now RC was the only option for ICE start

That's not true, there's already the MAVLink command for engine start/stop. I use it regularly. Granted, there's no button to send that message in Planner currently. I've always done it through plugins. But I could add it to the actions dropdown.

Copy link
Contributor

@tridge tridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also loose the low PWM on RC failure protection of STARTCHN_MIN.

that protection is essential. The combination of RFD900x with ICE is very common on large quadplanes, and it is still extremely hard to get this right due to the poor UI of the RFD900x. Making the ArduPilot code neater and more consistent is nice, but is not more important than protections like this.

@tridge
Copy link
Contributor

tridge commented Nov 24, 2024

@IamPete1 note that on aircraft of this type, the start chan is likely the only "aux" function on the aircraft.

@IamPete1
Copy link
Member Author

@IamPete1 note that on aircraft of this type, the start chan is likely the only "aux" function on the aircraft.

With this change they no longer need to setup the physical switch. So they can move to no aux functions at all.

How would you feel about moving to a new aux function (with no param conversion), this would force users to acknowledge the change.

The only other way round it is to move the min param to rc channels and apply it to all aux functions.

Or we keep the existing behaviour and add a new aux function that the gcs can use.

The key goal here is to expose the aux function to the gcs.

@robertlong13
Copy link
Collaborator

The key goal here is to expose the aux function to the gcs.

Is the key goal to expose an aux function to the GCS, or to give the GCS the ability to start and stop the engine? ArduPilot/MissionPlanner#3451

I suppose the aux function allows you to set the engine to a state that ignores mission command engine kills and ignore Q_LAND_ICE_CUT, but I think that's actually a recipe for more confusion.

Again, I'm actually in favor of having the aux function for this (and I think the min protection is not that essential), but I think GCSs should actually use the mavlink command, not the aux function, unless there's a good reason to do otherwise.

@IamPete1
Copy link
Member Author

IamPete1 commented Dec 9, 2024

No good options really, might try again in a year or two.

@IamPete1
Copy link
Member Author

IamPete1 commented Dec 13, 2024

I have moved to to the suggested trigger structure so AP_ICE can check the triggering PWM. There remain two issues:

  • The low/mid/high trigger points and the debounce time have changed.
  • The min PWM is applied on the edge triggered aux function. This means if there is a low PWM that results in the trigger being ignored it will not trigger until the PWM goes to mid or high and then back to low. It will not trigger when the PWM returns to to a valid low PWM value.

@@ -1410,7 +1418,7 @@ bool RC_Channel::run_aux_function(AUX_FUNC ch_option, AuxSwitchPos pos, AuxFuncT
// @Field: pos: switch position when function triggered
// @FieldValueEnum: pos: RC_Channel::AuxSwitchPos
// @Field: source: source of auxiliary function invocation
// @FieldValueEnum: source: RC_Channel::AuxFuncTriggerSource
// @FieldValueEnum: source: RC_Channel::AuxFuncTrigger::Source
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems link the logger docs don't like two level deep enums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Plane WikiNeeded needs wiki update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants